package com.myproject.proxy.jdk;

import java.lang.reflect.Proxy;

public class JdkProxyTest {

    public static void main(String[] args) {

        System.out.println(JdkProxyTest.class.getClassLoader());

        RealSubject realSubject = new RealSubject();
        System.out.println(realSubject);
        //realSubject.sayHello();
        SubjectInvocationHandler invocationHandler = new SubjectInvocationHandler(realSubject);
        Subject subject = (Subject) Proxy.newProxyInstance(realSubject.getClass().getClassLoader(),realSubject.getClass().getInterfaces(),invocationHandler);

        subject.sayHello();
        subject.sayYes();
        System.out.println(subject.getClass());
        System.out.println(subject.getClass().getClassLoader());


    }
}
